package com.jasonli.controller;

import com.jasonli.domain.User;
import com.jasonli.service.UserService;
import com.mysql.cj.Session;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/{username}/{password}")
    public Result getByUsernameAndPassword(@PathVariable String username, @PathVariable String password, HttpSession session) {
        User newUser = userService.getByUsernameAndPassword(username, password);
        System.out.println("getByUsernameAndPassword is running");
        boolean flag = newUser != null ? true : false;
        return new Result(flag ? Code.LOGIN_OK:Code.LOGIN_ERR,flag);
    }
}
